﻿namespace DeltaGroup.WheelOfJeopardy.Model
{
    using System.ComponentModel;

    public class Contestant : INotifyPropertyChanged
    {
        #region Fields

        private int _freeTurnCount;
        private bool _isPlaying;
        private int _score;

        #endregion Fields

        #region Events

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Events

        #region Properties

        /// <summary>
        /// Gets or sets the free turn count.
        /// </summary>
        /// <value>The free turn count.</value>
        public int FreeTurnCount
        {
            get { return _freeTurnCount; }
            set
            {
                _freeTurnCount = value;
                FirePropertyChanged("FreeTurnCount");
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is playing.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is playing; otherwise, <c>false</c>.
        /// </value>
        public bool IsPlaying
        {
            get { return _isPlaying; }
            set
            {
                _isPlaying = value;
                FirePropertyChanged("IsPlaying");
            }
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name
        {
            get; set;
        }

        /// <summary>
        /// Gets or sets the score.
        /// </summary>
        /// <value>The score.</value>
        public int Score
        {
            get { return _score; }
            set
            {
                _score = value;
                FirePropertyChanged("Score");
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Fires the property changed.
        /// </summary>
        /// <param name="name">The name.</param>
        private void FirePropertyChanged(string name)
        {
            if (PropertyChanged == null)
                return;

            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

        #endregion Methods
    }
}